import Mock from "mockjs";

const service = () => {
    //登录
    Mock.mock(`/login`, config => {
        const {user, pwd} = JSON.parse(config.body);
        if (user === "admin" && pwd) {
            return {
                message: "请求已经成功处理",
                code: 200,
                timestamp: new Date().getTime(),
                data: {
                    userId: Mock.mock("@guid"),
                    authToken: Mock.mock("@guid"),
                    realName: "FuLin"
                }
            };
        }
        return {
            message: "用户名或密码错误",
            code: 500,
            timestamp: new Date().getTime()
        };
    });


    //获取菜单
    // 菜单获取
    Mock.mock(`/menus`, {
        message: "请求已经成功处理",
        code: 200,
        data: [
            {
                path: "/",
                name: "index",
                icon: "md-speedometer",
                compName: "index",
                compPath: "/index"
            },
            {
                path: "/test",
                name: "Test",
                icon: "md-document",
                compName: "Test",
                compPath: "/Test"
            },
            {
                path: "/hello",
                name: "Hello",
                icon: "md-chatbubbles",
                children: [
                    {
                        path: "/hello/hello-world",
                        name: "HelloWorld",
                        icon: "md-text",
                        compName: "HelloWorld",
                        compPath: "/hello/helloWorld"
                    }
                ]
            }
        ],
        timestamp: new Date().getTime()
    });

};

export default service;



